//
//  KLProgressHUD.h
//  hud
//
//  Created by admin on 16/2/2.
//  Copyright © 2016年 静持大师. All rights reserved.
//

#import <MBProgressHUD.h>

typedef void(^Completed)();
// 如果NSErroe的code == kNoHUDErrorCode, 则不弹出error HUD
static NSInteger const kNoHUDErrorCode = 10000;

@interface KLProgressHUD : MBProgressHUD

//**********************************  等待框 **********************************
//********************************** 等待框 **********************************
+ (nullable instancetype)showWaitingHUD;
+ (nullable instancetype)showWaitingHUDWithSuperView:(nullable UIView *)superView;
+ (nullable instancetype)showWaitingHUDWithMessage:(nullable NSString *)message;

/**
 *  显示一个菊花等待框
 *
 *  @param superView 传 nil 表示加在 window 上
 *  @param message   加载提示语,可以传 nil
 *
 *  @return          KLProgressHUD 实例
 */
+ (nullable instancetype)showWaitingHUDWithSuperView:(nullable UIView *)superView message:(nullable NSString *)message;


//********************************** 普通提示框 **********************************
//********************************** 普通提示框 **********************************
/** 参数:message */
+ (nullable instancetype)showPromptHUDWithMessage:(nonnull NSString *)message;

/** 参数:message、time */
+ (nullable instancetype)showPromptHUDWithMessage:(nonnull NSString *)message andTime:(float)sec;

/** 参数:superView、message */
+ (nullable instancetype)showPromptHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message;

/** 参数:superView、message、time */
+ (nullable instancetype)showPromptHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message andTime:(float)sec;

/** 参数:superView、message、completed */
+ (nullable instancetype)showPromptHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message completed:(nullable Completed)completed;

/**
 *  普通提示框, 参数:superView、message、time、completed
 *  HUD 永远都是不可交互的
 *
 *  @param superView 加载到那个 view 上, 传 nil 表示加载 window 上
 *  @param message   消息
 *  @param sec       HUD 持续的时间
 *  @param completed HUD消失后需要处理的事件block
 */
+ (nullable instancetype)showPromptHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                           andTime:(float)sec completed:(nullable Completed)completed;


//********************************** 状态(成功或失败)提示 **********************************
//********************************** 状态(成功或失败)提示 **********************************
/** 参数:message */
+ (void)showSuccessHUDWithMessage:(nonnull NSString *)message;

/** 参数:message、isHudEnable */
+ (void)showSuccessHUDWithMessage:(nonnull NSString *)message isHudEnable:(BOOL)isHudEnable;

/** 参数:superView、message、isHudEnable */
+ (void)showSuccessHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                        isHudEnable:(BOOL)isHudEnable;

/** 参数:superView、message、isHudEnable、time */
+ (void)showSuccessHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                        isHudEnable:(BOOL)isHudEnable andTime:(float)sec;

/** 参数:superView、message、isHudEnable、completed */
+ (void)showSuccessHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                        isHudEnable:(BOOL)isHudEnable completed:(nullable Completed)completed;

/**
 *  成功状态提示框, 参数:superView、message、isHudEnable、time、completed
 *
 *  @param superView   加载到那个 view 上, 传 nil 表示加载 window 上
 *  @param message     消息
 *  @param isHudEnable 1、HUD 是否是可以交互的,传NO表示HUD不可以交互, 则当前界面的其他控件是可交互的, 反之亦然
                       2、default is NO
 *  @param sec         HUD 持续的时间
 *  @param completed   HUD消失后需要处理的事件block
 */
+ (void)showSuccessHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                        isHudEnable:(BOOL)isHudEnable andTime:(float)sec completed:(nullable Completed)completed;


//------------------------------------------
/** 参数:message */
+ (void)showErrorHUDWithMessage:(nonnull NSString *)message;

/** 参数:message、isHudEnable */
+ (void)showErrorHUDWithMessage:(nonnull NSString *)message isHudEnable:(BOOL)isHudEnable;

/** 参数:superView、message、isHudEnable */
+ (void)showErrorHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                      isHudEnable:(BOOL)isHudEnable;

/** 参数:superView、message、isHudEnable、time */
+ (void)showErrorHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                      isHudEnable:(BOOL)isHudEnable andTime:(float)sec;


/**
 *  失败的弹框, 参数:superView、message、isHudEnable、time、completed
 *
 *  @param superView   加载到那个 view 上, 传 nil 表示加载 window 上
 *  @param message     消息
 *  @param isHudEnable 1、HUD 是否是可以交互的,传NO表示HUD不可以交互, 则当前界面的其他控件是可交互的, 反之亦然
                       2、default is NO
 *  @param sec         HUD 持续的时间
 *  @param completed   HUD消失后需要处理的事件block
 */
+ (void)showErrorHUDWithSuperView:(nullable UIView *)superView message:(nonnull NSString *)message
                      isHudEnable:(BOOL)isHudEnable andTime:(float)sec completed:(nullable Completed)completed;


//------------------------------------------
/** 参数:error */
+ (void)showErrorHUDWithError:(nullable NSError *)error;

/** 参数:superView、error */
+ (void)showErrorHUDWithSuperView:(nullable UIView *)superView error:(nullable NSError *)error;

/**
 *  失败的弹框(惨况的message根据error.code 而定), 参数:superView、error、time
 *  这个弹框是用在网络请求失败出现, 其中 HUD 是不可以交互的
 *
 *  @param superView 加载到那个 view 上, 传 nil 表示加载 window 上
 *  @param error     错误
 *  @param sec       HUD 持续的时间
 */
+ (void)showErrorHUDWithSuperView:(nullable UIView *)superView error:(nullable NSError *)error andTime:(float)sec;

//-----------------------------------------
/**
 *  显示原生的AlertView
 */
+ (void)showAlertViewWithTitle:(NSString *)title;
+ (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message;
@end
